import html2canvas from 'html2canvas'
import useWait from './useAwait'

async function useScreenShot(el: HTMLDivElement) {

    if(!el){
        return console.warn("el元素为空",el)
    }

    const canvas = await html2canvas(el, {
        useCORS: true,
        allowTaint: true,
    })

    await useWait(300)

    const imgData = canvas.toDataURL('image/png', 1.0)

    return imgData
}

export default useScreenShot
